<?php

use \app\assets\FrontAsset as Asset;

/* @var $this yii\web\View */
/* @var $errorCode integer */
/* @var $title string */
/* @var $message string */
/* @var $previousPage string */
/* @var $exception Exception */
/* @var $redirectList array */
/* @var $reasons array */


$this->title = $title;
?>
<div id="doc_main">
    <section class="bd clearfix">
        <div class="module-error">
            <div class="error-main clearfix">
                <div class="label"></div>
                <div class="info">
                    <h3 class="title">抱歉，<?= $message ?></h3>

                <?php if (!empty($reasons)) { ?>
                    <div class="reason">
                        <p>可能的原因：</p>
                        <?php $i = 1;?>
                        <?php foreach ($reasons as $k => $v) { ?>
                            <p><?=$i?>. <?=$v?></p>
                            <?php $i++; ?>
                        <?php }?>
                    </div>
                <?php } else if ($errorCode == 403) { ?>
                    <div class="reason">
                        <p>可能的原因：</p>
                        <p>1. 登录过了保质期。</p>
                        <p>2. 此页面您没有权限查看。</p>
                    </div>
                <?php } else { ?>
                    <div class="reason">
                        <p>可能的原因：</p>
                        <p>1. 手抖打错了。</p>
                        <p>2. 链接过了保质期。</p>
                        <p>3. 尝试多次无果，可直接联系站点管理员。</p>
                    </div>
                <?php } ?>
                    <div class="oper">
                        <?php if ($errorCode == 403) { ?>
                            <p><a href="javascript:void(0);" class="oper-item" id="toLogin">去登录&gt;</a></p>
                        <?php } else {?>
                            <p>
                            <?php foreach ($redirectList as $k => $v ) { ?>
                                <a href="<?=$v?>" class="oper-item"><?=$k?>&nbsp;&gt;</a>
                            <?php } ?>
                            </p>
                        <?php }?>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<?php
Asset::addCss($this, '/css/error.css');
Asset::addScript($this, "/js/jquery.min.js");
Asset::addScript($this, "/js/common.js");

$this->registerJs("
    if(self.frameElement === null) {
        jQuery('#toLogin').on('click', function() {
            window.location.href = \$w.getPageUrl('login');
        });
    }
    
");
?>
<script>
    function cancel() {
        var isIframe = $w.getParams('is_iframe');
        if (+isIframe === 1 && window.parent.instance) {
            window.parent.instance.pageDialog.show = false;
        } else window.history.back();
    }
</script>
